<include file="public/layout" />
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
	<div class="fixed-bar">
		<div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
			<div class="subject">
				<h3>自提点管理 - 编辑自提点</h3>
				<h5>网站系统自提点管理</h5>
			</div>
		</div>
	</div>
	<form class="form-horizontal" id="handleForm" action="{:U('Admin/Pickup/add')}" method="post">
		<input name="pickup_id" type="hidden" value="{$pickup['pickup_id']}" />
		<div class="ncap-form-default">
			<dl class="row">
				<dt class="tit">
					<label><em>*</em>自提点名称</label>
				</dt>
				<dd class="opt">
					<input type="text"  name="pickup_name" value="{$pickup.pickup_name}" class="input-txt">
					<p class="notic">自提点名称</p>
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label><em>*</em>自提点地址</label>
				</dt>
				<dd class="opt">
					<select name="province_id" id="province" onChange="get_city(this)">
						<option value="0">请选择</option>
						<volist name="province" id="p">
							<option <if condition="$pickup['province_id'] eq $p['id']">selected</if>  value="{$p.id}">{$p.name}</option>
						</volist>
					</select>
					<select name="city_id" id="city" onChange="get_area(this)">
						<option  value="0">请选择</option>
						<volist name="city" id="p">
							<option <if condition="$pickup['city_id'] eq $p['id']">selected</if>  value="{$p.id}">{$p.name}</option>
						</volist>
					</select>
					<select name="district_id" id="district">
						<option  value="0">请选择</option>
						<volist name="district" id="p">
							<option <if condition="$pickup['district_id'] eq $p['id']">selected</if>  value="{$p.id}">{$p.name}</option>
						</volist>
					</select>
					<p class="notic">自提点地址</p>
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label><em>*</em>供货商</label>
				</dt>
				<dd class="opt">
					<select name="suppliersid" id="suppliers_id">
						<option  value="0">不选则无供货商{$pickup['suppliers_id']}</option>
						<volist name="suppliers" id="s">
							<option <if condition="$pickup['suppliersid'] eq $s['suppliers_id']">selected="selected"</if>  value="{$s.suppliers_id}">{$s.suppliers_name}</option>
						</volist>
					</select>
					<p class="notic">供货商</p>
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label><em>*</em>详细地址</label>
				</dt>
				<dd class="opt">
					<textarea name="pickup_address" id="address" placeholder="详细地址" class="tarea" rows="6">{$pickup.pickup_address}</textarea>
					<p class="notic">详细地址</p>
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label>自提点联系人</label>
				</dt>
				<dd class="opt">
					<input type="text" name="pickup_contact" placeholder="自提点联系人" value="{$pickup.pickup_contact}" class="input-txt">
					<p class="notic"></p>
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label><em>*</em>自提点电话</label>
				</dt>
				<dd class="opt">
					<input type="text" name="pickup_phone" value="{$pickup.pickup_phone}" onpaste="this.value=this.value.replace(/[^\d-]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d-]/g,'')" class="input-txt">
					<p class="notic"></p>
				</dd>
			</dl>
		     <dl class="row">
		         <dt class="tit">
		             <label for="pickup_logo">自提点LOGO</label>
		         </dt>
		         <dd class="opt">
		             <div class="input-file-show">
		                 <span class="show">
		                     <a id="img_a" class="nyroModal" rel="gal" href="{$info.pickup_logo}">
		                         <i id="img_i" class="fa fa-picture-o" onmouseover="layer.tips('<img src={$pickup.pickup_logo}>',this,{tips: [1, '#fff']})" onmouseout="layer.closeAll()"></i>
		                     </a>
		                 </span>
		    	            <span class="type-file-box">
		                     <input type="text" id="pickup_logo" name="pickup_logo" value="{$pickup.pickup_logo}" class="type-file-text">
		                     <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
		                     <input class="type-file-file" onClick="GetUploadify(1,'','link','img_call_back')" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
		                 </span>
		             </div>
		             <span class="err"></span>
		             <p class="notic">默认网站LOGO,通用头部显示，最佳显示尺寸为240*60像素</p>
		         </dd>
		     </dl>

		     <!-- 店面相册-->        
	
             <dl class="row">
             	<dt class="tit">
             	    <label for="pickup_images">自提点形象图</label>
             	</dt>
             	<dd class="opt">
                  <div class="tab-pane" id="tab_goods_images">
                     <table class="table table-bordered">
                         <tbody>
                         <tr>                                    
                             <td>                                    
                             <foreach name="pickup_images" item="vo" key="k" >
                                 <div style="width:100px; text-align:center; margin: 5px; display:inline-block;" class="goods_xc">
                                     <input type="hidden" value="{$vo}" name="pickup_images[]">
                                     <a onClick="" href="{$vo}" target="_blank"><img width="100" height="100" src="{$vo}"></a>
                                     <br>
                                     <a href="javascript:void(0)" onClick="ClearPicArr2(this,'{$vo}')">删除</a>
                                 </div>
                             </foreach>
                             
                                 <div class="goods_xc" style="width:100px; text-align:center; margin: 5px; display:inline-block;">
                                     <input type="hidden" name="pickup_images[]" value="" />
                                     <a href="javascript:void(0);" onClick="GetUploadify(10,'','pickup','call_back2');"><img src="/public/images/add-button.jpg" width="100" height="100" /></a>
                                     <br/>
                                     <a href="javascript:void(0)">&nbsp;&nbsp;</a>
                                 </div>                                        
                             </td>
                         </tr>                                              
                         </tbody>
                     </table>
                 </div>
                 </dd>
             </dl>             
		     <!-- 店面相册-->

			<div class="bot"><a onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
		</div>
	</form>
</div>
<script type="text/javascript">
	function checkForm(){
		var pickup_name = $('input[name="pickup_name"]').val();
		var province_id = $('select[name="province_id"]').find('option:selected').val();
		var city_id = $('select[name="city_id"]').find('option:selected').val();
		var district_id = $('select[name="district_id"]').find('option:selected').val();
		var pickup_address = $('textarea[name="pickup_address"]').val();
		var pickup_phone = $('input[name="pickup_phone"]').val();
		var error = '';
		if(pickup_name == ''){
			error += '自提点名称不能为空 <br/>';
		}
		if(province_id==0){
			error += '请选择省份 <br/>';
		}
		if(city_id==0){
			error += '请选择城市 <br/>';
		}
		if(district_id==0){
			error += '请选择区域 <br/>';
		}
		if(pickup_address == ''){
			error += '请填写地址 <br/>';
		}
		if(error){
			//alert(error);
			layer.alert(error, {icon: 2});
			//	layer.msg('只想弱弱提示');
			return false;
		}
		$('#handleForm').submit();
	}
</script>
<script type="text/javascript">
    function img_call_back(fileurl_tmp)
    {
        $("#pickup_logo").val(fileurl_tmp);
        $("#img_a").attr('href', fileurl_tmp);
        $("#img_i").attr('onmouseover', "layer.tips('<img src="+fileurl_tmp+">',this,{tips: [1, '#fff']});");
    }
        // 上传商品相册回调函数
        function call_back2(paths){
            
            var  last_div = $(".goods_xc:last").prop("outerHTML");	
            for (i=0;i<paths.length ;i++ )
            {                    
                $(".goods_xc:eq(0)").before(last_div);	// 插入一个 新图片
                    $(".goods_xc:eq(0)").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
                $(".goods_xc:eq(0)").find('img').attr('src',paths[i]);// 修改他的图片路径
                    $(".goods_xc:eq(0)").find('a:eq(1)').attr('onclick',"ClearPicArr2(this,'"+paths[i]+"')").text('删除');
                $(".goods_xc:eq(0)").find('input').val(paths[i]); // 设置隐藏域 要提交的值
            } 			   
        }
        /*
         * 上传之后删除组图input     
         * @access   public
         * @val      string  删除的图片input
         */
        function ClearPicArr2(obj,path)
        {
        	$.ajax({
                        type:'GET',
                        url:"{:U('Admin/Uploadify/delupload')}",
                        data:{action:"del", filename:path},
                        success:function(){
                               $(obj).parent().remove(); // 删除完服务器的, 再删除 html上的图片				 
                        }
    		});
    		// 删除数据库记录
        	$.ajax({
                        type:'GET',
                        url:"{:U('Admin/Goods/del_goods_images')}",
                        data:{filename:path},
                        success:function(){
                              //		 
                        }
    		});		
        }
</script>
</body>
</html>